#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;
int n = 0;
vector<int> v;
int Min = 100000000;
void recursion(vector<bool> dp, int x, int count)
{
    if (x == v.size() - 1)
    {
        if (count < Min) Min = count;
        return;
    }
    if (dp[x] == true)
    {
        return;
    }
    else
    {
        dp[x] = true;
    }
    count++;
    if (x >= 0)
    {
        for (int i = x + 1;i <= x + v[x] && i < v.size();i++)
        {
            recursion(dp, i, count);
        }
    }
    else
    {
        if (x + v[x] < 0) recursion(dp, 0, count);
        for (int i = x + v[x];i >= 0;i--)
        {
            recursion(dp, i, count);
        }
    }
    return;
}
int main()
{
    cin >> n;
    int tmp = 0;
    for (int i = 0;i < n;i++)
    {
        cin >> tmp;
        v.push_back(tmp);
    }
    vector<bool> dp(n, false);
    recursion(dp, 0, 0);
    if (Min == 100000000) cout << "-1";
    else cout << Min << endl;
    return 0;
}